Skip to content

Command Palette: Make admin bar trigger a native group element#11171

Open
ellatrix wants to merge 3 commits intoWordPress:trunkfrom
ellatrix:tweaks/command-palette-admin-bar-searchbar
Open

Command Palette: Make admin bar trigger a native group element#11171
ellatrix wants to merge 3 commits intoWordPress:trunkfrom
ellatrix:tweaks/command-palette-admin-bar-searchbar

Conversation

@ellatrix
Copy link
Member

@ellatrix ellatrix commented Mar 5, 2026

Trac: https://core.trac.wordpress.org/ticket/64672

image
Screen.Recording.2026-03-05.at.09.53.12.mov

Summary

Follow-up to #11108. Makes the command palette trigger a native admin bar group element instead of a regular node in root-default, as suggested in review.

  • Registers command-palette as its own group under root using add_group(), with the trigger node inside it — this produces a sibling <ul> to root-default and top-secondary
  • Converts .quicklinks to display: flex so the three groups lay out naturally: left items, centered command palette, right items
  • Both side groups use flex: 1 1 0; min-width: fit-content — equal space when the viewport is wide (perfect centering), but they won't shrink below their content on narrow viewports
  • Command palette group uses flex: 0 0 auto between them

Existing float declarations on <li> elements become harmless (floats are ignored on flex items per CSS spec).

Alternative approach

An alternative would be to bypass the node/group API entirely and render the command palette directly in WP_Admin_Bar::_render() as a standalone <button> element — a sibling to the <ul> groups inside .quicklinks. This would give full control over the markup (semantic <button> instead of <a> inside <li> inside <ul>), but requires modifying class-wp-admin-bar.php and hardcoding the element into the admin bar's render method. The group-based approach here is more straightforward since it reuses the existing API and keeps all the command palette logic in admin-bar.php.

Test plan

  • Load any wp-admin page: command palette button should appear centered in the admin bar
  • Click it: should open the command palette
  • Check front-end pages: button should NOT appear
  • Resize viewport — left group should push the command palette rightward rather than shrinking
  • Test RTL layout
  • Test mobile viewport (admin bar collapse behavior)
  • Test different color schemes (modern, default)

🤖 Generated with Claude Code

t-hamano and others added 3 commits March 2, 2026 19:40
Instead of adding the command palette as a regular node in
root-default, register it as its own group under root. This makes
it a sibling `<ul>` to root-default and top-secondary, allowing
flexbox centering on `.quicklinks` without being constrained to
the `<li>` node structure.

- Add `command-palette` as a group with `add_group()`, place the
  trigger node inside it as `command-palette-trigger`
- Convert `.quicklinks` to `display: flex` for layout control
- Both side groups use `flex: 1 1 0; min-width: fit-content` so
  they share equal space but never shrink their content
- Command palette group uses `flex: 0 0 auto` to sit centered
  between them naturally

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link

github-actions bot commented Mar 5, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props wildworks, ellatrix, mcsf, westonruter, sabernhardt, ocean90, annezazu, 4thhubbard.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@ellatrix ellatrix requested review from mcsf and t-hamano March 5, 2026 07:58
@westonruter
Copy link
Member

So the command palette is not accessible on mobile. Why shouldn't it be?

@ellatrix
Copy link
Member Author

ellatrix commented Mar 5, 2026

It's the same as #11108, I don't think I changed anything there. I guess it will have to be added explicitly to the mobile version of the admin bar

Copy link
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! When I actually saw the center-aligned search bar, I realized it was quite prominent 😅

There are two things that concern me.

  1. With several plugins installed, the search bar may become misaligned:
    Image
  2. When I open the editor, you may find the search bar overlapping, which can be a bit confusing:
    Image

Personally, I think going with #11160 might have the least impact. What do you think? cc @sabernhardt

@ellatrix
Copy link
Member Author

ellatrix commented Mar 5, 2026

With several plugins installed, the search bar may become misaligned:

I think that's fine, it still looks ok?

When I open the editor, you may find the search bar overlapping, which can be a bit confusing:

What o you mean here? What overlaps what?

Personally, I think going with #11160 might have the least impact. What do you think? cc @sabernhardt

Would need approval from design

@ocean90
Copy link
Member

ocean90 commented Mar 5, 2026

Something that looks like an input/search field but isn't one feels wrong.

When I open the editor, you may find the search bar overlapping, which can be a bit confusing:

What o you mean here? What overlaps what?

They're not overlapping, but there are two of these bars right next to each other.

@t-hamano
Copy link
Contributor

t-hamano commented Mar 5, 2026

What overlaps what?

I was referring to these two places. There are two search bars close to each other that both trigger the command palette.

double-search-bar

@ellatrix
Copy link
Member Author

ellatrix commented Mar 5, 2026

@t-hamano Isn't that a problem in your PR too? How has it been addressed elsewhere? Or is there a proposal to unify them.

Something that looks like an input/search field but isn't one feels wrong.

@ocean90 It's the same for the editor document bar 🙂

@t-hamano
Copy link
Contributor

t-hamano commented Mar 5, 2026

Isn't that a problem in your PR too? How has it been addressed elsewhere?

Two approaches have been proposed that do not use a search bar in the first place.

@annezazu
Copy link

annezazu commented Mar 5, 2026

Personally, I think going with #11160 might have the least impact. What do you think?

Chatting with @mtias about this and a more condensed command‑K control is okay for beta 3 if needed, rather than the search icon. The search icon alone is not enough.

@annezazu
Copy link

annezazu commented Mar 9, 2026

Let's land this ahead of the next beta so we can get more testing. Previously, the smaller command‑K control would have worked to get an initial version in to a prior beta but, at this point, it's important we stick with the design and project leadership direction.

Copy link
Contributor

@mcsf mcsf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Let's go with this and see if it needs any polishing before 7.0.

}

#wpadminbar #wp-admin-bar-command-palette-trigger .ab-icon {
transform: scaleX(-1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clever 😄

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is copied from @t-hamano's PR

Copy link
Member

@westonruter westonruter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What again about the mobile viewport? Having the admin bar expose an item to access the command palette on mobile is arguably even more important since the keyboard is not normally displayed when an input isn't focused. I like the approach in @sabernhardt's PR: #11160

Copy link

@sabernhardt sabernhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made #11160, hoping to avoid picking this one apart.

Something that looks like an input/search field but isn't one feels wrong.

It's the same for the editor document bar 🙂

The proposed toolbar link is not the same. The document bar element in the editor canvas does not have a search icon or empty space between the icon and the keyboard shortcut text. Anyone who sees something that looks like this should expect it to be an input field (or maybe the overlay could cover it, with similar styling, as in Slack).

}

#wpadminbar .quicklinks {
display: flex;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Introducing flex—without wrap—in core intensifies an existing problem for sites with crowded toolbars. That can push the profile links and/or others off the screen, making it impossible to reach the Log Out link (unless you use the keyboard to navigate). Then adding an element that is 215 pixels wide would break more sites, and in a worse way.

Profile menu off-screen at 1,000 pixels wide, with a few plugins activated:

crowded toolbar, missing profile link

Profile menu expanded with the Enter key:

crowded toolbar showing expanded profile menu

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying something where if it doesn't fit, we fall back to normal toolbar behavior.

shrink.mov


#wpadminbar #wp-admin-bar-command-palette-trigger .ab-item {
width: 200px;
background: #757575;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#757575 does not give enough contrast behind the #f0f0f1 text in the Fresh scheme (4.05:1).

Command palette link in Fresh scheme

The hover and focus states typically have less contrast.

Low contrast for Modern (default) scheme on hover/focus:
3.47:1 #7b90ff against #3c434a

Modern scheme on focus

Very low contrast for Fresh on hover/focus:
1.96:1 #72aee6 against #757575

Fresh scheme on focus

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this needs to be changed to a variable

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually sorry, I guess it needs an override for that color scheme


.wp-responsive-open div#wp-responsive-toggle a {
// ToDo: make inset border
// ToDo: make inset border;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated change.

I do not even find a #wp-responsive-toggle anywhere, even in code history as of r26402, so the two rulesets probably can be removed entirely (later).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@4thhubbard
Copy link

This looks good. Please land this so we have time to test sooner rather than later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants